package com.dingmouren.smaple.paletteimageview.slice;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.dingmouren.paletteimageview.PaletteImageView;
import com.dingmouren.smaple.paletteimageview.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.media.image.PixelMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class GlideTestSlice extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_slice_glide_test);

        final PaletteImageView paletteImageView = (PaletteImageView) findComponentById(ResourceTable.Id_img);
        Glide.with(this).asBitmap().load(getString(ResourceTable.String_glide_url)).into(new SimpleTarget<PixelMap>() {
            @Override
            public void onResourceReady(@NotNull PixelMap pixelMap, @Nullable Transition<? super PixelMap> transition) {
                paletteImageView.setPixelMap(pixelMap);
            }
        });

    }
}
